//
//  UIImage+Color.m
//  ToolExample
//
//  Created by 唐可雄 on 2019/7/13.
//  Copyright © 2019 swustyc. All rights reserved.
//

#import "UIImage+Color.h"

#import <CoreGraphics/CoreGraphics.h>

@implementation UIImage (Color)

+ (instancetype)imageWithColor:(UIColor *)color {
    CGRect rect = CGRectMake(0, 0, 1, 1);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, color.CGColor);
    CGContextFillRect(context, rect);
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}

@end
